//
//  PilotSettingsViewController.m
//  EVETracker
//
//  Created by Scott Guyer on 7/19/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "RootPilotViewController.h"
#import "EVEApi.h"
#import "EditPilotViewController.h"
#import "PilotListViewController.h"
#import "EditPilotViewController.h"
#import "PilotSettingsViewController.h"
#import "defs.h"


@implementation PilotSettingsViewController

@synthesize rootPilotVC, pilotListVC, navVC;


- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
	if ( (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) != nil )
	{
		NSArray* nibObjects = [[NSBundle mainBundle] loadNibNamed:nibNameOrNil owner:self options:nil];
		if ( nibObjects == nil )
		{
			NSLog(@"%s can't load nib", __FUNCTION__);
			return nil;
		}
		
		CGRect f = navVC.view.frame;
		f.origin.x = f.origin.y = 0; // this was getting set to 20 somehow :(
		navVC.view.frame = f;
		[self.view addSubview:navVC.view];
		
		[self.view setAutoresizesSubviews:YES];
		
		[navVC.view setAutoresizesSubviews:YES];
	}
	
	return self;
}


- (void) setPilotList:(NSMutableArray*)pilots 
{
	[pilotListVC setPilots:pilots];
}


- (IBAction) doneEditing:(id)sender
{
	[Character savePilots:pilotListVC.pilotList];
	[rootPilotVC showPilots];
}


- (void)viewDidLoad 
{
	[super viewDidLoad];
}


- (void)viewWillAppear:(BOOL)animated 
{
	[navVC viewWillAppear:animated];
//	[pilotListVC viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated 
{
	[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated 
{
	[navVC viewWillDisappear:animated];
//	[pilotListVC viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void) didReceiveMemoryWarning
{
}

- (void)dealloc 
{
	NSLog(@"%s 0x%x", __FUNCTION__, self);
	
	WIPE( navVC)
	WIPE( pilotListVC)
	WIPE( rootPilotVC)
		
	[super dealloc];
}


@end
